package com.xdm.ui.adapter.android;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AndroidDecoratedTextView extends LinearLayout {
	private TextView textView;
	private ImageView imageView;
	
	public AndroidDecoratedTextView(Context context, String text, Drawable decoration) {
		super(context);

		this.setOrientation(HORIZONTAL);

		imageView = new ImageView(context);
		imageView.setImageDrawable(decoration);
		// left, top, right, bottom
		imageView.setPadding(0, 2, 5, 0);
		addView(imageView,  new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		
		textView = new TextView(context);
		textView.setText(text);
		addView(textView, new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	}

	public void setText(String text) {
		textView.setText(text);
	}
	
	public void setDecoration(Drawable decoration) {
		imageView.setImageDrawable(decoration);
	}

	public TextView getTextView() {
		return textView;
	}

}